package org.itboys.kitchen.service.mysql.income;


import org.itboys.kitchen.entity.mysql.income.KitchenIncomeProduct;
import org.itboys.kitchen.util.NumberUtil;
import org.itboys.mongodb.service.BaseMySqlService;
import org.itboys.param.PageResult;
import org.itboys.param.ParamUtil;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


/**
 * 作者：jiangxiong
 * 日期：2016年11月25日
 * 联系方式 ：empty90911@126.com
 * 描述：农厨_钱包（收益）_产品_service_web
 *
 */
@Service
public class KitchenIncomeProductService extends BaseMySqlService<KitchenIncomeProduct> {


	/**
	 * 新增或修改
	 * @param incomeProduct
	 */
	public void saveIncomeProduct(KitchenIncomeProduct incomeProduct) {

		if(incomeProduct.getId()==0l){
			incomeProduct.setNumber(NumberUtil.generateNumber("IP"));
			super.insert(incomeProduct);
		}else{
			super.update(incomeProduct);
		}
		
	}
	/**
	 * 分页查询
	 * @param request
	 * @return
	 */
	public PageResult<KitchenIncomeProduct> select(HttpServletRequest request){
		Map<String,Object> param = ParamUtil.packageMysqlPageParam(request,"number");
		return  new PageResult<KitchenIncomeProduct>(super.select(param),super.count(param));
	}

	/**
	 *
	 * @param id
	 * @param status
	 */
	public void change(Long id,Integer status) {
		super.update(new KitchenIncomeProduct(id,status));
	}
}
